<?php
class Component extends Eloquent {
	
	public function orders() {
		return $this->belongsToMany('Order', 'orders_components');
	}

	public function products() {
		return $this->belongsToMany('Product', 'products_components');
	}
	
	public function costsCentres() {
		return $this->belongsToMany('CostsCentre', 'components_costs_centres')->orderBy('step');
	}
	
	public function isEditable() {
		return $this->orders()->count() === 0;
	}
	
}